<?php
    header("Access-Control-Allow-Origin:*");
    header("Content-type:text/html;charset=utf-8");

    //连接数据库
    require "./connect.php";

    # 获取前端传入的数据:
    $username = @$_POST["username"];
    $password = @$_POST["password"];

    //数据库sql语句 : 从表中获取数据
    $select_SQL = "SELECT username,password FROM user";
    $select_res = mysql_query($select_SQL,$con);  //运行sql语句
    if($select_res){
        while($row = mysql_fetch_array($select_res)){
            if($row["username"] === $username && $row["password"] ===  $password){
                $json_arr = array("statu" => "success" , "stateCode" => "1");
                // setcookie("tocken",$username,null,"/");
                die(json_encode($json_arr));  //返回状态值
            }
        }
    }
    $json_arr = array("statu" => "error", "stateCode" => "5", "errorType" => "用户名密码不匹配");
    die(json_encode($json_arr));
?>